package tj.eskhata.pos.common;

import java.util.Date;
import java.util.Locale;

import org.apache.wicket.Application;
import org.apache.wicket.Request;
import org.apache.wicket.Session;
import org.apache.wicket.protocol.http.WebSession;

import tj.eskhata.pos.domain.ClPart;
import tj.eskhata.pos.domain.ClPoint;
import tj.eskhata.pos.domain.User;

public class WiaSession extends WebSession {

  public static WiaSession get() {
    return (WiaSession) Session.get();
  }

  private User		user;
  private ClPart	part;
  private ClPoint	point;
  private Date		opDate;
  private boolean	isAdmin;
  
  public WiaSession(Request request) {
    super(request);
    setLocale(new Locale("ru"));
  }

  public synchronized User getUser() {
    return user;
  }

  public synchronized boolean isAuthenticated() {
    return (user != null);
  }

  public synchronized void setUser(User user) {
    this.user = user;
    dirty();
  }

	public synchronized ClPart getPart() {
		return part;
	}
	
	public synchronized void setPart(ClPart part) {
		this.part = part;
	}

	public synchronized ClPoint getPoint() {
		return point;
	}

	public synchronized void setPoint(ClPoint point) {
		this.point = point;
	}

	public synchronized Date getOpDate() {
		return opDate;
	}

	public synchronized void setOpDate(Date opDate) {
		this.opDate = opDate;
	}

	public boolean getIsAdmin() {
		return isAdmin;
	}

	public void setIsAdmin(boolean isAdmin) {
		this.isAdmin = isAdmin;
	}
}
